import Router from "vue-router";
import Vue from 'vue'
Vue.use(Router);
// 解决导航菜单的时候，重复点击报错的问题
// https://my.oschina.net/u/4256357/blog/4304073
const originalPush = Router.prototype.push
Router.prototype.push = function push(location:any) {
  return (originalPush.call(this, location) as any).catch((err:any) => err)
}

export default new Router({
  // mode:'history',
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '*',
      redirect: '/404'
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/login/login.vue'),
      meta: {title: '登录'}
    },
    {
      path: '/index',
      name: 'index',
      component: () => import('@/views/index.vue'),
      meta: {title: '首页'}
    },
    {
      path: '/404',
      name: '404',
      component: () => import('@/views/other-page/404.vue'),
      meta: {title: '404'}
    },
  ],
});